package com.example.Administrator.shoujiweishi.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.example.Administrator.shoujiweishi.R;
import com.example.Administrator.shoujiweishi.activities.base.BaseActivity;
import com.example.Administrator.shoujiweishi.utils.ActivityCollecter;
import com.example.Administrator.shoujiweishi.utils.DanceWageTimer;
import com.example.Administrator.shoujiweishi.views.RatingBar;
import com.example.Administrator.shoujiweishi.views.RatingView;

import java.util.Random;

import butterknife.BindView;
import butterknife.OnClick;

public class MainActivity extends BaseActivity {


    @BindView(R.id.rating_view)
    RatingView ratingView;
    @BindView(R.id.tv_num)
    TextView tv_Num;
    int one = new Random().nextInt(10) + 1;
    int two = new Random().nextInt(10) + 1;
    int three = new Random().nextInt(10) + 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    @Override
    public int getContentXML() {
        return R.layout.activity_main;
    }

    @Override
    public void initData() {


    }

    @Override
    public void initView() {
//根据产生的随机数one来定 （>=8）高、(<=5)低、(8>one>5)中    三元运算符  表达式? 结果一 :结果二
        ratingView.addRatingBar(new RatingBar(one, one>=8?"清晰度高":(one<=5)?"清晰度低":"清晰度中"));
        ratingView.addRatingBar(new RatingBar(two, two>=8?"流畅度高":(two<=5)?"流畅度低":"流畅度中"));
        ratingView.addRatingBar(new RatingBar(three, three>=8?"安全度高":(three<=5)?"安全度低":"安全度中"));
        ratingView.show();
        ratingView.setAnimatorListener(new RatingView.AnimatorListener() {
            @Override
            public void onRotateStart() {

            }

            @Override
            public void onRotateEnd() {
                //跳数效果
                int num = (int) ((one * 0.5 + two * 0.3 + three * 0.2) * 10);
                // tv_Num.setText(num+"");
                long totalExecuteTime = DanceWageTimer.getTotalExecuteTime(num, 20);
                DanceWageTimer danceWageTimer = new DanceWageTimer(totalExecuteTime, 20, tv_Num, num);
                danceWageTimer.start();

            }

            @Override
            public void onRatingStart() {

            }

            @Override
            public void onRatingEnd() {

            }
        });
        //tv_Num.setText((one*0.5+two*0.3+three*0.2));

    }

    @OnClick(R.id.iduser)
   public void skipUserActivity(View view){
       // Toast.makeText(this, "======", Toast.LENGTH_SHORT).show();
       startActivity(new Intent(MainActivity.this,UserActivity.class));
   }
    @OnClick(R.id.huafeiliuliang)
    public void tiaozhuan(View view){
        // Toast.makeText(this, "======", Toast.LENGTH_SHORT).show();
        startActivity(new Intent(this,BBXaa.class));
    }
}
